package com.example.demo.ai.llm.config;

import org.noear.redisx.RedisClient;
import org.noear.solon.ai.embedding.EmbeddingConfig;
import org.noear.solon.ai.embedding.EmbeddingModel;
import org.noear.solon.ai.rag.repository.RedisRepository;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;

/**
 * @author airhead
 */
@Configuration
public class LlmConfig {
  @Bean
  public EmbeddingModel embeddingModel(@Inject("${demo.llm.embed}") EmbeddingConfig config) {
    return EmbeddingModel.of(config).build();
  }

  @Bean
  public RedisRepository repository(
      EmbeddingModel embeddingModel, @Inject("${demo.llm.repo.redis}") RedisClient client) {
    return new RedisRepository(embeddingModel, client.openSession().jedis());
  }
}
